#include<bits/stdc++.h>
using namespace std;
long long n,l,r,so,sl,sr;
int main() {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld%lld%lld",&n,&l,&r);
	sl=l%n;
	sr=r%n;
	so=((r-r%n)-1)%n;
	if(r-r%n-1<n||r-r%n-1<l) so=0;
	printf("%lld",max(max(sl,sr),so));
	return 0;
}
